package com.he.ymw.controller;

import com.github.pagehelper.PageInfo;
import com.he.ymw.pojo.Product;
import com.he.ymw.service.ProductService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;

@Controller
public class CategoryController {

    @Resource
    ProductService productService;

    /**
     * 分页查询所有商品
     */
    @RequestMapping("/toCategoryList")
    public String toCategoryList(Model model, Integer page, Integer pageSize) {
        List<Product> products = productService.findProducts2(page, pageSize);
        model.addAttribute("pageInfo", new PageInfo(products));
        model.addAttribute("products", products);
        return "CategoryList";
    }

}
